package com.zj.osm.view.mine;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.AppUtils;
import com.zj.osm.R;
import com.zj.osm.view.BaseActivity;
import com.zj.utils.view.TitleBar;


/**
 * 关于朱江
 * 嘿嘿
 */
public class AboutActivity extends BaseActivity implements View.OnClickListener {


    private Context context;
    private TitleBar aboutTitleBar;

    @SuppressLint("ResourceType")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_about);
        context = this;
        initView();
    }

    /**
     * 初始化页面以及点击事件
     */
    @SuppressLint("SetTextI18n")
    private void initView() {
        TextView txt_msgtip = findViewById(R.id.txt_msgtip);
        TextView txt_about = findViewById(R.id.txt_about1);
        txt_about.setOnClickListener(view -> {
            Intent intent = new Intent();
            intent.setClass(AboutActivity.this, AboutUsActivity.class);
            startActivity(intent);
        });
        TextView banben = findViewById(R.id.banben);

        banben.setText("移动设计(" + AppUtils.getAppVersionName() + ")");

        txt_msgtip.setOnClickListener(view -> {
            Intent intent = new Intent();
            intent.setClass(AboutActivity.this, ShuomingActivity.class);
            startActivity(intent);
        });
        TextView txt_yinsi = findViewById(R.id.txt_yinsi);
        txt_yinsi.setOnClickListener(view -> {
            //添加确定按钮
            //添加返回按钮
            new AlertDialog.Builder(AboutActivity.this).setTitle("清除缓存")//设置对话框标题

                    .setMessage("是否清除缓存数据！")//设置显示的内容

                    .setPositiveButton("确定", (dialog, which) -> {//确定按钮的响应事件

                        // TODO Auto-generated method stub

                        finish();

                    }).setNegativeButton("返回", (dialog, which) -> {//响应事件

                // TODO Auto-generated method stub

                Log.i("alertdialog", " 请保存数据！");

            }).show();//在按键响应事件中显示此对话框
        });

        aboutTitleBar = findViewById(R.id.aboutTitleBar);
        aboutTitleBar.setTitle("关于");
        aboutTitleBar.setBackImageVisiable(true);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        finish();
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.activity_ib_back) {//放入item_id来告知bottomActivity需要显示那个activity
            finish();
        }
    }
}
